import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import locale from 'element-plus/lib/locale/lang/zh-cn'
import App from './App.vue'
import router from './router'
import store from './store'
import * as echarts from 'echarts'
import 'echarts/map/js/china'
// 阿里图标库
import "./assets/iconfont/iconfont.css"
// 全局css
import "./assets/css/common.scss"

router.beforeEach(async(to, from, next) => {
  // console.log(to)
  let token = sessionStorage.getItem('token');
  if(to.path === '/login') return next();
  if(!token) {
    next('/login')
  } 
  next()
})
const app = createApp(App)
app.config.globalProperties.$echarts  = echarts
app.use(store)
app.use(router)
app.use(ElementPlus,{locale})

app.mount('#app')
